package dhbw.GUI.Menu;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import dhbw.Data.Language;
import dhbw.Data.Settings;
import dhbw.GUI.Window.WindowChangePassword;
import dhbw.GUI.Window.WindowInfo;
import dhbw.GUI.Window.WindowPersonalien;
import Main.MyController;

public class MenuProfessor extends JMenu implements ActionListener{

	private JMenuItem changePasswordItem,ownDataItem;
	private MyController myc;
	
	public MenuProfessor(MyController myc)
	{
		this.myc=myc;
		buildMenu();
	}

	/**
	 * Build JMenu Professor
	 */
	private void buildMenu()
	{
		changePasswordItem = new JMenuItem(Language.CHANGEPASSWORD[myc.getLanguage()]);
		changePasswordItem.addActionListener(this);
		ownDataItem = new JMenuItem(Language.PERSONALDATA[myc.getLanguage()]);
		ownDataItem.addActionListener(this);
		ownDataItem.setIcon(Settings.PERSONAL_DATA_ICON);
		changePasswordItem.setIcon(Settings.CHANGEPW_ICON);
		this.add(changePasswordItem);
		this.add(ownDataItem);
		this.setText(Language.PROFESSOR[myc.getLanguage()]);
	}
	
	@Override
	/**
	 * Click-Listener for JMenu
	 */
	public void actionPerformed(ActionEvent arg0) {
		if (arg0.getSource().equals(changePasswordItem)) {
			new WindowChangePassword(this.myc);
		}
		if (arg0.getSource().equals(ownDataItem)) {
			new WindowPersonalien(false, myc, this.myc.getActiveUser());
		}
	}
}
